import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { createI18n } from 'vue-i18n'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIcons from '@element-plus/icons-vue'
import VChart from 'vue-echarts'
import App from './App.vue'
import router from './router'
import zhCN from './locales/zh-CN'
import enUS from './locales/en-US'
import {
  Odometer,
  User,
  Setting,
  SwitchButton,
  Expand,
  Fold,
  Monitor,
  Moon,
  Star,
  DataLine,
  Brush
} from '@element-plus/icons-vue'

const i18n = createI18n({
  legacy: false,
  locale: localStorage.getItem('lang') || 'zh-CN',
  messages: {
    'zh-CN': zhCN,
    'en-US': enUS
  }
})

const app = createApp(App)
const pinia = createPinia()

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIcons)) {
  app.component(key, component)
}

app.component('v-chart', VChart)
app.use(pinia)
app.use(i18n)
app.use(ElementPlus, {
  config: {
    dropdown: {
      teleported: true,
      trigger: 'click'
    }
  }
})
app.use(router)
app.mount('#app')
